home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Mac / Tools / macfreeze / macgen_rsrc.py < prev    next >
Encoding:
Python Source  |  2000-06-23  |  998 b   |  38 lines

  1. """macgen_info - Generate PYC resource file only"""
  2. import EasyDialogs
  3. import py_resource
  4. import Res
  5. import sys
  6.  
  7. def generate(output, module_dict, debug=0, preload=1):
  8.     fsid = py_resource.create(output)
  9.     
  10.     for name, module in module_dict.items():
  11.         mtype = module.gettype()
  12.         if mtype not in ['module', 'package']:
  13.             continue
  14.         location = module.__file__
  15.         
  16.         if location[-4:] == '.pyc':
  17.             # Attempt corresponding .py
  18.             location = location[:-1]
  19.         if location[-3:] != '.py':
  20.             print '*** skipping', location
  21.             continue
  22.             
  23.         id, name = py_resource.frompyfile(location, name, preload=preload, 
  24.                 ispackage=mtype=='package')
  25.         if debug > 0:
  26.             print 'PYC resource %5d\t%s\t%s'%(id, name, location)
  27.     
  28.     Res.CloseResFile(fsid)
  29.     
  30. def warnings(module_dict):
  31.     problems = 0
  32.     for name, module in module_dict.items():
  33.         if module.gettype() not in ('builtin', 'module', 'package'):
  34.             problems = problems + 1
  35.             print 'Warning: %s not included: %s %s'%(name, module.gettype(), module)
  36.     return problems
  37.     
  38.